package com.dlnu.sujiwords.service.Impl;

import com.dlnu.sujiwords.dao.RoleMapper;
import com.dlnu.sujiwords.domain.client.AjaxResult;
import com.dlnu.sujiwords.domain.pojo.Role;
import com.dlnu.sujiwords.service.IRoleService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;


@Service
public class RoleServiceImpl implements IRoleService {
    @Resource
    private RoleMapper mapper;
    @Override
    public AjaxResult selRole() {
        return AjaxResult.success("成功查询",mapper.selectAll());
    }
    @Override
    public AjaxResult addRole(Role rol) {
        byte rid =(byte) (mapper.selectAll().size() + 1);
        rol.setRid(rid);
        if(mapper.insert(rol) > 0)return AjaxResult.success("成功插入");
        return AjaxResult.success("无法插入请联系开发人员");
    }

    @Override
    public AjaxResult updRole(Role role) {
        return mapper.updateByPrimaryKey(role) > 0? AjaxResult.success("修改成功"):AjaxResult.success("修改失败");
    }

    @Override
    public AjaxResult delRole(Byte delrole) {
        return mapper.deleteByPrimaryKey(delrole)>0?AjaxResult.success("成功删除"):AjaxResult.success("删除失败请联系开发者");
    }


}
